home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / awesom_1 / data1.cab / Program_Executable_Files / AaxVC / AaxDlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-04-29  |  2.4 KB  |  106 lines

  1. // AaxDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "Aax.h"
  6. #include "AaxDlg.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CAaxDlg dialog
  16.  
  17. CAaxDlg::CAaxDlg(CWnd* pParent /*=NULL*/)
  18.     : CDialog(CAaxDlg::IDD, pParent)
  19. {
  20.     m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  21. }
  22.  
  23. BEGIN_MESSAGE_MAP(CAaxDlg, CDialog)
  24.     ON_WM_PAINT()
  25.     ON_WM_QUERYDRAGICON()
  26. END_MESSAGE_MAP()
  27.  
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CAaxDlg message handlers
  30. BOOL CAaxDlg::OnInitDialog()
  31. {
  32.     CDialog::OnInitDialog();
  33.  
  34.     SetIcon(m_hIcon, TRUE);            // Set big icon
  35.     SetIcon(m_hIcon, FALSE);        // Set small icon
  36.     
  37.     return TRUE;  // return TRUE  unless you set the focus to a control
  38. }
  39.  
  40. void CAaxDlg::OnPaint() 
  41. {
  42.     if (IsIconic())
  43.     {
  44.         CPaintDC dc(this); // device context for painting
  45.  
  46.         SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  47.  
  48.         // Center icon in client rectangle
  49.         int cxIcon = GetSystemMetrics(SM_CXICON);
  50.         int cyIcon = GetSystemMetrics(SM_CYICON);
  51.         CRect rect;
  52.         GetClientRect(&rect);
  53.         int x = (rect.Width() - cxIcon + 1) / 2;
  54.         int y = (rect.Height() - cyIcon + 1) / 2;
  55.  
  56.         // Draw the icon
  57.         dc.DrawIcon(x, y, m_hIcon);
  58.     }
  59.     else
  60.     {
  61.         CDialog::OnPaint();
  62.     }
  63. }
  64.  
  65. // The system calls this to obtain the cursor to display while the user drags
  66. //  the minimized window.
  67. HCURSOR CAaxDlg::OnQueryDragIcon()
  68. {
  69.     return (HCURSOR) m_hIcon;
  70. }
  71.  
  72. BEGIN_EVENTSINK_MAP(CAaxDlg, CDialog)
  73.     ON_EVENT(CAaxDlg, IDC_AAXBUTTONCTRL_TOP, -600 /* Click */, OnClickTop, VTS_NONE)
  74.     ON_EVENT(CAaxDlg, IDC_AAXBUTTONCTRL_BOTTOM, -600 /* Click */, OnClickBottom, VTS_NONE)
  75.     ON_EVENT(CAaxDlg, IDC_AAXBUTTONCTRL_LEFT, -600 /* Click */, OnClickLeft, VTS_NONE)
  76.     ON_EVENT(CAaxDlg, IDC_AAXBUTTONCTRL_RIGHT, -600 /* Click */, OnClickRight, VTS_NONE)
  77. END_EVENTSINK_MAP()
  78.  
  79. void CAaxDlg::OnClickTop() 
  80. {
  81.     Print("Click Top");
  82. }
  83.  
  84. void CAaxDlg::OnClickBottom() 
  85. {
  86.     Print("Click Bottom");
  87. }
  88.  
  89. void CAaxDlg::OnClickLeft() 
  90. {
  91.     Print("Click Left");
  92. }
  93.  
  94. void CAaxDlg::OnClickRight() 
  95. {
  96.     Print("Click Right");
  97. }
  98.  
  99. void CAaxDlg::Print(LPCSTR str)
  100. {
  101.     CString strConsole;
  102.     GetDlgItem(IDC_EDIT)->GetWindowText(strConsole);
  103.     strConsole = CString(str) + "\r\n" + strConsole;
  104.     GetDlgItem(IDC_EDIT)->SetWindowText(strConsole);
  105. }
  106.